<template>
  <div class="projectConfig">
      <template v-for="(config,index) of configList">
            <!-- 分类字典配置 -->
            <category-config v-if="config.type=='CATEGORY'" :bizId="config.id" :title="config.name" :rootId="config.value" :key="index" :style="{order:config.sort}"></category-config>
            <!-- 字典配置 -->
            <level-config v-if="config.type=='DICT'" :bizId="config.id" :title="config.name" :dictId="config.value" :key="index" :style="{order:config.sort}"></level-config>
            <!-- 时间范围 -->
            <time-range-config v-if="config.type=='TIME_RANGE'" :bizId="config.id" :title="config.name" :value="config.value" :key="index" :style="{order:config.sort}"></time-range-config>
      </template>
  </div>
</template>

<script>
import { postAction, getAction, deleteAction } from '@/api/manage'
import CategoryConfig from './modules/CategoryConfig'
import LevelConfig from './modules/DictConfig'
import TimeRangeConfig from './modules/TimeRangeConfig'
export default {
  components: {
    CategoryConfig,
    LevelConfig,
    TimeRangeConfig
  },
  data() {
    return {
      configList: [],
      url: {
        config: '/bizConfig/list'
      }
    }
  },
  created() {
    this.loadConfig()
  },
  methods: {
    loadConfig() {
      return new Promise(resolve => {
        getAction(this.url.config, {
          module: 'research_project'
        }).then(res => {
          if (res.success && res.result) {
            this.configList = res.result.records
          } else {
            this.configList = []
          }
        })
      })
    }
  }
}
</script>

<style scoped>

.projectConfig > div:not(:first-child){
     margin-top: 20px;   
}
</style>
